package org.his.controller;

import java.util.Collection;
import java.util.List;

import org.his.entity.Doctor;
import org.his.entity.Drug;
import org.his.service.DoctorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/doctor")
public class DoctorController {
	@Autowired
	private DoctorService doctorService;
	
	@RequestMapping("querybyform")
	@ResponseBody
	public Collection<Doctor> quertbyform(Doctor qDoctor){
		List<Doctor> qDoctors = doctorService.queryByFrom(qDoctor);
		return qDoctors;
	}
	
	//增加医生
		@RequestMapping(value = "/adddoctor",produces = "text/html;charset=UTF-8")
		@ResponseBody
		public String addDrug(Doctor addDoctor) {
			int count = doctorService.addDoctor(addDoctor);
			if (count > 0) {
				return "{\"success\":\"true\",\"message\":\"医生增加成功\"}";
			}
			return "{\"success\":\"flase\",\"message\":\"医生增加失败\"}";
		}
		//删除医生
		@RequestMapping(value = "/deletedoctor",produces = "text/html;charset=UTF-8")
		@ResponseBody
		public String deleteDrug(@RequestParam("doctorno") String deleteDoctorno) {
			int count =doctorService.deleteDoctor(deleteDoctorno);
					
			if (count > 0) {
				return "{\"success\":\"true\",\"message\":\"医生删除成功\"}";
			}
			return "{\"success\":\"flase\",\"message\":\"医生删除失败\"}";
		}
}
